#setwd("C:[SET WORKING DRIVE]")


mydata<- read.csv("Data5Sessions.csv")
attach(mydata)
labels(mydata)
obs<-length(mydata$Subject)
NumSess<-5
NumSubj<-60
library(ggplot2)
library(grob)
library(psych)
library(effsize)


#Data Setup
#Game 1 (Game 1 in experimental order)
Game1<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==1){Game1[count]<-mydata$Choice[i]; count<- count+1}}
#Game 2 (Game 21 in experimental order)
Game2<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==21){Game2[count]<-mydata$Choice[i]; count<- count+1}}
#Game 3 (Game 40 in experimental order)
Game3<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==40){Game3[count]<-mydata$Choice[i]; count<- count+1}}
#Game 4 (Game 13 in experimental order)
Game4<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==13){Game4[count]<-mydata$Choice[i]; count<- count+1}}
#Game 5 (Game 5 in experimental order)
Game5<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==5){Game5[count]<-mydata$Choice[i]; count<- count+1}}
#Game 6 (Game 31 in experimental order)
Game6<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==31){Game6[count]<-mydata$Choice[i]; count<- count+1}}
#Game 7 (Game 27 in experimental order)
Game7<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==27){Game7[count]<-mydata$Choice[i]; count<- count+1}}
#Game 8 (Game 17 in experimental order)
Game8<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==17){Game8[count]<-mydata$Choice[i]; count<- count+1}}
#Game 9 (Game 9 in experimental order)
Game9<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==9){Game9[count]<-mydata$Choice[i]; count<- count+1}}
#Game 10 (Game 36 in experimental order)
Game10<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==36){Game10[count]<-mydata$Choice[i]; count<- count+1}}
#Game 11 (Game 11 in experimental order)
Game11<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==11){Game11[count]<-mydata$Choice[i]; count<- count+1}}
#Game 12 (Game 29 in experimental order)
Game12<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==29){Game12[count]<-mydata$Choice[i]; count<- count+1}}
#Game 13 (Game 26 in experimental order)
Game13<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==26){Game13[count]<-mydata$Choice[i]; count<- count+1}}
#Game 14 (Game 19 in experimental order)
Game14<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==19){Game14[count]<-mydata$Choice[i]; count<- count+1}}
#Game 15 (Game 22 in experimental order)
Game15<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==22){Game15[count]<-mydata$Choice[i]; count<- count+1}}
#Game 16 (Game 38 in experimental order)
Game16<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==38){Game16[count]<-mydata$Choice[i]; count<- count+1}}
#Game 17 (Game 7 in experimental order)
Game17<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==7){Game17[count]<-mydata$Choice[i]; count<- count+1}}
#Game 18 (Game 15 in experimental order)
Game18<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==15){Game18[count]<-mydata$Choice[i]; count<- count+1}}
#Game 19 (Game 33 in experimental order)
Game19<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==33){Game19[count]<-mydata$Choice[i]; count<- count+1}}
#Game 20 (Game 3 in experimental order)
Game20<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==3){Game20[count]<-mydata$Choice[i]; count<- count+1}}
#Game 21 (Game 24 in experimental order)
Game21<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==24){Game21[count]<-mydata$Choice[i]; count<- count+1}}
#Game 22 (Game 37 in experimental order)
Game22<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==37){Game22[count]<-mydata$Choice[i]; count<- count+1}}
#Game 23 (Game 8 in experimental order)
Game23<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==8){Game23[count]<-mydata$Choice[i]; count<- count+1}}
#Game 24 (Game 32 in experimental order)
Game24<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==32){Game24[count]<-mydata$Choice[i]; count<- count+1}}
#Game 25 (Game 16 in experimental order)
Game25<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==16){Game25[count]<-mydata$Choice[i]; count<- count+1}}
#Game 26 (Game 34 in experimental order)
Game26<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==34){Game26[count]<-mydata$Choice[i]; count<- count+1}}
#Game 27 (Game 14 in experimental order)
Game27<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==14){Game27[count]<-mydata$Choice[i]; count<- count+1}}
#Game 28 (Game 4 in experimental order)
Game28<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==4){Game28[count]<-mydata$Choice[i]; count<- count+1}}
#Game 29 (Game 20 in experimental order)
Game29<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==20){Game29[count]<-mydata$Choice[i]; count<- count+1}}
#Game 30 (Game 28 in experimental order)
Game30<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==28){Game30[count]<-mydata$Choice[i]; count<- count+1}}
#Game 31 (Game 25 in experimental order)
Game31<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==25){Game31[count]<-mydata$Choice[i]; count<- count+1}}
#Game 32 (Game 6 in experimental order)
Game32<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==6){Game32[count]<-mydata$Choice[i]; count<- count+1}}
#Game 33 (Game 23 in experimental order)
Game33<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==23){Game33[count]<-mydata$Choice[i]; count<- count+1}}
#Game 34 (Game 2 in experimental order)
Game34<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==2){Game34[count]<-mydata$Choice[i]; count<- count+1}}
#Game 35 (Game 39 in experimental order)
Game35<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==39){Game35[count]<-mydata$Choice[i]; count<- count+1}}
#Game 36 (Game 10 in experimental order)
Game36<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==10){Game36[count]<-mydata$Choice[i]; count<- count+1}}
#Game 37 (Game 18 in experimental order)
Game37<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==18){Game37[count]<-mydata$Choice[i]; count<- count+1}}
#Game 38 (Game 35 in experimental order)
Game38<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==35){Game38[count]<-mydata$Choice[i]; count<- count+1}}
#Game 39 (Game 12 in experimental order)
Game39<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==12){Game39[count]<-mydata$Choice[i]; count<- count+1}}
#Game 40 (Game 30 in experimental order)
Game40<-numeric(NumSubj); count<-1; for(i in 1:obs){if(mydata$Round[i]==30){Game40[count]<-mydata$Choice[i]; count<- count+1}}


#Turn '2' entries into '0' entries
for (i in 1:NumSubj){
  ifelse(Game1[i]==2,Game1[i]<-0,Game1[i]<-1)
  ifelse(Game2[i]==2,Game2[i]<-0,Game2[i]<-1)
  ifelse(Game3[i]==2,Game3[i]<-0,Game3[i]<-1)
  ifelse(Game4[i]==2,Game4[i]<-0,Game4[i]<-1)
  ifelse(Game5[i]==2,Game5[i]<-0,Game5[i]<-1)
  ifelse(Game6[i]==2,Game6[i]<-0,Game6[i]<-1)
  ifelse(Game7[i]==2,Game7[i]<-0,Game7[i]<-1)
  ifelse(Game8[i]==2,Game8[i]<-0,Game8[i]<-1)
  ifelse(Game9[i]==2,Game9[i]<-0,Game9[i]<-1)
  ifelse(Game10[i]==2,Game10[i]<-0,Game10[i]<-1)
  
  ifelse(Game11[i]==2,Game11[i]<-0,Game11[i]<-1)
  ifelse(Game12[i]==2,Game12[i]<-0,Game12[i]<-1)
  ifelse(Game13[i]==2,Game13[i]<-0,Game13[i]<-1)
  ifelse(Game14[i]==2,Game14[i]<-0,Game14[i]<-1)
  ifelse(Game15[i]==2,Game15[i]<-0,Game15[i]<-1)
  ifelse(Game16[i]==2,Game16[i]<-0,Game16[i]<-1)
  ifelse(Game17[i]==2,Game17[i]<-0,Game17[i]<-1)
  ifelse(Game18[i]==2,Game18[i]<-0,Game18[i]<-1)
  ifelse(Game19[i]==2,Game19[i]<-0,Game19[i]<-1)
  ifelse(Game20[i]==2,Game20[i]<-0,Game20[i]<-1)
  
  ifelse(Game21[i]==2,Game21[i]<-0,Game21[i]<-1)
  ifelse(Game22[i]==2,Game22[i]<-0,Game22[i]<-1)
  ifelse(Game23[i]==2,Game23[i]<-0,Game23[i]<-1)
  ifelse(Game24[i]==2,Game24[i]<-0,Game24[i]<-1)
  ifelse(Game25[i]==2,Game25[i]<-0,Game25[i]<-1)
  ifelse(Game26[i]==2,Game26[i]<-0,Game26[i]<-1)
  ifelse(Game27[i]==2,Game27[i]<-0,Game27[i]<-1)
  ifelse(Game28[i]==2,Game28[i]<-0,Game28[i]<-1)
  ifelse(Game29[i]==2,Game29[i]<-0,Game29[i]<-1)
  ifelse(Game30[i]==2,Game30[i]<-0,Game30[i]<-1)
  
  ifelse(Game31[i]==2,Game31[i]<-0,Game31[i]<-1)
  ifelse(Game32[i]==2,Game32[i]<-0,Game32[i]<-1)
  ifelse(Game33[i]==2,Game33[i]<-0,Game33[i]<-1)
  ifelse(Game34[i]==2,Game34[i]<-0,Game34[i]<-1)
  ifelse(Game35[i]==2,Game35[i]<-0,Game35[i]<-1)
  ifelse(Game36[i]==2,Game36[i]<-0,Game36[i]<-1)
  ifelse(Game37[i]==2,Game37[i]<-0,Game37[i]<-1)
  ifelse(Game38[i]==2,Game38[i]<-0,Game38[i]<-1)
  ifelse(Game39[i]==2,Game39[i]<-0,Game39[i]<-1)
  ifelse(Game40[i]==2,Game40[i]<-0,Game40[i]<-1)
}


#4 different types
GameA<-c(Game1,Game2,Game3,Game4,Game5,Game6,Game7,Game8,Game9,Game10)
GameB<-c(Game11,Game12,Game13,Game14,Game15,Game16,Game17,Game18,Game19,Game20)
GameC<-c(Game21,Game22,Game23,Game24,Game25,Game26,Game27,Game28,Game29,Game30)
GameD<-c(Game31,Game32,Game33,Game34,Game35,Game36,Game37,Game38,Game39,Game40)

#FIGURE 9

#Statistical Kruskal wallace test of the games created above. Are these 4 sets different? 
GameSet<-c(GameA, GameB, GameC, GameD)
Type<-c("b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",                 "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",        "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",                 "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",       "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",  "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2","b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",         
        "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",     "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",         "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",          "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",     "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",         "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4","b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4")
KSdata <- data.frame(GameSet, Type)
kruskal.test(GameSet ~ Type, data = KSdata)


#Tests across b values in Figure 9 LEFT PANEL
t.test(GameA,GameB)
t.test(GameB,GameC)
t.test(GameC,GameD)

wilcox.test(GameA,GameB)
wilcox.test(GameB,GameC)
wilcox.test(GameC,GameD)

cohen.d(GameA ~ GameD)

#Tests across b values in Figure 9 RIGHT PANEL
#Compare set X and Y where these games are equivalent from RR's perspective (Diff at .0002)
GameX<-c(Game1,Game2,Game3,Game4,Game15,Game16,Game17,Game18,Game19)
GameY<-c(Game21,Game22,Game23,Game24,Game35,Game36,Game37,Game38,Game39)

wilcox.test(GameX,GameY)
t.test(GameX,GameY)



##### Setting up data for Figure 9 LEFT PANEL
#This works for the average
Game4Props<-numeric(4)
a<-table(c(Game1, Game2, Game3, Game4,Game5, Game6,Game7, Game8,Game9, Game10))
Game4Props[1]<-a[names(a)==1]/600
a<-table(c(Game11, Game12, Game13, Game14,Game15, Game16,Game17, Game18,Game19, Game20))
Game4Props[2]<-a[names(a)==1]/600
a<-table(c(Game21, Game22, Game23, Game24,Game25, Game26,Game27, Game28,Game29, Game30))
Game4Props[3]<-a[names(a)==1]/600
a<-table(c(Game31, Game32, Game33, Game34,Game35, Game36,Game37, Game38,Game39, Game40))
Game4Props[4]<-a[names(a)==1]/600

#This works for the SD for each game
SE4<-numeric(4)
for (i in 1:4){
  SE4[i] <- sqrt((Game4Props[i]*(1-Game4Props[i]))/600)
}

###FIGURES

##### Setting up data for Figure 9 RIGHT PANEL
#This works for the average
Game2Props<-numeric(2)
a<-table(c(Game1,Game2,Game3,Game4,Game15,Game16,Game17,Game18,Game19))
Game2Props[1]<-a[names(a)==1]/540
a<-table(c(Game21,Game22,Game23,Game24,Game35,Game36,Game37,Game38,Game39))
Game2Props[2]<-a[names(a)==1]/540

SE2<-numeric(2)
for (i in 1:2){
  SE2[i] <- sqrt((Game2Props[i]*(1-Game2Props[i]))/540)
}


df2<- data.frame(c('b1 (smallest)', 'b2', 'b3', 'b4'), Game4Props, SE4)

#p<- ggplot(df2, aes(x=c('b1 \n (smallest)', 'b2', 'b3', 'b4 \n (largest)'), y=Game4Props)) + 
p1<- ggplot(df2, aes(x=c('b1', 'b2', 'b3', 'b4'), y=Game4Props)) + 
  geom_pointrange(aes(ymin=Game4Props-SE4, ymax=Game4Props+SE4))+labs(title="", x="", y = "")+
  theme_classic() + ylim(.3,.6)+ ggtitle("Proportion in Action X")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))#+ annotation_custom(my_grob1)+ annotation_custom(my_grob2)+ annotation_custom(my_grob3)
print(p1)
#ABOVE IS FIGURE 9 LEFT PANEL


df3<- data.frame(c('b1 / b2', 'b3 / b4'), Game2Props, SE2)
p2<- ggplot(df3, aes(x=c('b1 or b2 \n ', 'b3 or b4 \n '), y=Game2Props)) + 
  geom_pointrange(aes(ymin=Game2Props-SE2, ymax=Game2Props+SE2))+labs(title="", x="", y = "")+
  theme_classic() + ylim(.3,.6)+ ggtitle("Proportion in Action X")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))#+ annotation_custom(my_grob1)
print(p2)
#ABOVE IS FIGURE 9 RIGHT PANEL

grid.arrange(p1,p2, ncol = 2, nrow = 1)
#ABOVE PUTS THE TWO FIGURES  TOGETHER


#FIGURE 10 and TABLE 2

#Setting up the data for Figure 10

#This works for the average
GameProps<-numeric(40)
a<-table(Game1); GameProps[1]<-a[names(a)==1]/60
a<-table(Game2); GameProps[2]<-a[names(a)==1]/60
a<-table(Game3); GameProps[3]<-a[names(a)==1]/60
a<-table(Game4); GameProps[4]<-a[names(a)==1]/60
a<-table(Game5); GameProps[5]<-a[names(a)==1]/60
a<-table(Game6); GameProps[6]<-a[names(a)==1]/60
a<-table(Game7); GameProps[7]<-a[names(a)==1]/60
a<-table(Game8); GameProps[8]<-a[names(a)==1]/60
a<-table(Game9); GameProps[9]<-a[names(a)==1]/60
a<-table(Game10); GameProps[10]<-a[names(a)==1]/60
a<-table(Game11); GameProps[11]<-a[names(a)==1]/60
a<-table(Game12); GameProps[12]<-a[names(a)==1]/60
a<-table(Game13); GameProps[13]<-a[names(a)==1]/60
a<-table(Game14); GameProps[14]<-a[names(a)==1]/60
a<-table(Game15); GameProps[15]<-a[names(a)==1]/60
a<-table(Game16); GameProps[16]<-a[names(a)==1]/60
a<-table(Game17); GameProps[17]<-a[names(a)==1]/60
a<-table(Game18); GameProps[18]<-a[names(a)==1]/60
a<-table(Game19); GameProps[19]<-a[names(a)==1]/60
a<-table(Game20); GameProps[20]<-a[names(a)==1]/60
a<-table(Game21); GameProps[21]<-a[names(a)==1]/60
a<-table(Game22); GameProps[22]<-a[names(a)==1]/60
a<-table(Game23); GameProps[23]<-a[names(a)==1]/60
a<-table(Game24); GameProps[24]<-a[names(a)==1]/60
a<-table(Game25); GameProps[25]<-a[names(a)==1]/60
a<-table(Game26); GameProps[26]<-a[names(a)==1]/60
a<-table(Game27); GameProps[27]<-a[names(a)==1]/60
a<-table(Game28); GameProps[28]<-a[names(a)==1]/60
a<-table(Game29); GameProps[29]<-a[names(a)==1]/60
a<-table(Game30); GameProps[30]<-a[names(a)==1]/60
a<-table(Game31); GameProps[31]<-a[names(a)==1]/60
a<-table(Game32); GameProps[32]<-a[names(a)==1]/60
a<-table(Game33); GameProps[33]<-a[names(a)==1]/60
a<-table(Game34); GameProps[34]<-a[names(a)==1]/60
a<-table(Game35); GameProps[35]<-a[names(a)==1]/60
a<-table(Game36); GameProps[36]<-a[names(a)==1]/60
a<-table(Game37); GameProps[37]<-a[names(a)==1]/60
a<-table(Game38); GameProps[38]<-a[names(a)==1]/60
a<-table(Game39); GameProps[39]<-a[names(a)==1]/60
a<-table(Game40); GameProps[40]<-a[names(a)==1]/60


#This works for calculating the Standard errors for each game
SE<-numeric(40)
for (i in 1:40){
  SE[i] <- sqrt((GameProps[i]*(1-GameProps[i]))/60)
}

#Test for significant correlations between Obs and the 4 models
Nash<-c(0.56, 0.73, 0.81, 0.85, 0.52, 0.63, 0.52, 0.7, 0.59, 0.51, 0.56, 0.73, 0.81, 0.85, 0.52, 0.63, 0.52, 0.7, 0.59, 0.51, 0.56, 0.73, 0.81, 0.85, 0.52, 0.63, 0.52, 0.7, 0.59, 0.51, 0.56, 0.73, 0.81, 0.85, 0.52, 0.63, 0.52, 0.7, 0.59, 0.51)
r<-c(1.25,     2.75,     4.25,     5.75,     1.1,     1.7,     1.06,     2.3,     1.44,     1.05,     1.25,     2.75,     4.25,     5.75,     1.1,     1.7,     1.06,     2.3,     1.44,     1.05,     1.25,     2.75,     4.25,     5.75,     1.1,     1.7,     1.06,     2.3,     1.44,     1.05,     1.25,     2.75,     4.25,     5.75,     1.1,     1.7,     1.06,     2.3,     1.44,     1.05)
rNEW<-log(r)
OP<-c(18,      30,      42,      54,      42,      54,      66,      66,      78,      90,      18,      30,      42,      54,      42,      54,      66,      66,      78,      90,      18,      30,      42,      54,      42,      54,      66,      66,      78,      90,      18,      30,      42,      54,      42,      54,      66,      66,      78,      90)
RR<-c(0.64,      0.3,      0.2,      0.15,      0.83,      0.54,      0.89,      0.4,      0.66,      0.91,      0.05,      0.03,      0.02,      0.02,      0.56,      0.38,      0.25,      0.29,      0.16,      0.48,      0.63,      0.3,      0.21,      0.14,      0.02,      0.02,      0.01,      0.01,      0.01,      0.2,      0.8,      0.68,      0.56,      0.39,      0.53,      0.43,      0.24,      0.31,      0.16,      0.01)

#NASH PLOT AND STATISTICS
cor.test(Nash, GameProps, method=c("pearson"))
LMNash<-lm(GameProps~Nash)
summary(LMNash)
AIC(LMNash)
BIC(LMNash)
rmseNash<-sqrt(mean(LMNash$residuals^2))
maeNash<-mean(abs(LMNash$residuals))
NashData<-data.frame(GameProps,Nash)

NashPlot<-ggplot(NashData, aes(x=Nash, y=GameProps)) + geom_point(size=3)+
  geom_smooth(method=lm, linetype="dashed", color="black")+
  labs(title="",x="Nash" , y = "Prop. in Action X")+ylim(.10, .75)+ theme_classic()+ ggtitle("")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title.x = element_text(face="italic"))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))
print(NashPlot)

#r PLOT AND STATISTICS
cor.test(rNEW, GameProps, method=c("pearson"))
LMrNEW<-lm(GameProps~rNEW)
summary(LMrNEW)
AIC(LMrNEW)
BIC(LMrNEW)
rNEWmser<-sqrt(mean(LMrNEW$residuals^2))
maerNEW<-mean(abs(LMrNEW$residuals))

rNEWData<-data.frame(GameProps,rNEW)
rNEWPlot<-ggplot(rNEWData, aes(x=rNEW, y=GameProps)) + geom_point(size=3)+
  geom_smooth(method=lm, linetype="dashed", color="black")+
  labs(title="",x="r" , y = "Prop. in Action X")+ylim(.1, .75)+ theme_classic()+ ggtitle("")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+
  theme(axis.title.x = element_text(face="italic"))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))
print(rNEWPlot)
#table(rNEW)

#OP PLOT AND STATISTICS
cor.test(OP, GameProps, method=c("pearson"))
LMOP<-lm(GameProps~OP)
summary(LMOP)
AIC(LMOP)
BIC(LMOP)
rmseOP<-sqrt(mean(LMOP$residuals^2))
maeOP<-mean(abs(LMOP$residuals))

OPData<-data.frame(GameProps,OP)
OPPlot<-ggplot(OPData, aes(x=OP, y=GameProps)) + geom_point(size=3)+
  geom_smooth(method=lm, linetype="dashed", color="black")+
  labs(title="",x="OP" , y = "Prop. in Action X")+ylim(.1, .75)+ theme_classic()+ ggtitle("")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+
  theme(axis.title.x = element_text(face="italic"))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))
print(OPPlot)

table(OP)

#RR PLOT AND STATISTICS
cor.test(RR, GameProps, method=c("pearson"))
LMRR<-lm(GameProps~RR)
summary(LMRR)
AIC(LMRR)
BIC(LMRR)
rmseRR<-sqrt(mean(LMRR$residuals^2))
maeRR<-mean(abs(LMRR$residuals))

table(RR)


RRData<-data.frame(GameProps,RR)
RRPlot<-ggplot(RRData, aes(x=RR, y=GameProps)) + geom_point(size=3)+
  geom_smooth(method=lm, linetype="dashed", color="black")+
  labs(title="",x="RR" , y = "Prop. in Action X")+ylim(.1, .75)+ theme_classic()+ ggtitle("")+ theme(plot.title = element_text(family="serif", size=20,hjust = 0.5))+ 
  theme(axis.title = element_text(family="serif", size=20,hjust = 0.5))+
  theme(axis.title.x = element_text(face="italic"))+ 
  theme(axis.text.x = element_text(family="serif", size=12))+ 
  theme(axis.text.y = element_text(family="serif", size=12))
print(RRPlot)

#FIGURE 10
grid.arrange(NashPlot, rPlot, RRPlot, OPPlot, ncol = 2, nrow = 2)


#FIGURE 20 and TABLE 4 (APPENDIX F)

#SET 1
#X-axis labeled with "b's" instead of game numbers
Orderz<-c("b1","b2","b3","b4")
aa<-1
bb<-11
cc<-21
dd<-31
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set1Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 1, 11, 21, & 31", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
print(Set1Fig)

#SET 2
aa<-2
bb<-12
cc<-22
dd<-32
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set2Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 2, 12, 22, & 32", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set2Fig)

#SET 3
aa<-3
bb<-13
cc<-23
dd<-33
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set3Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 3, 13, 23, & 33", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set3Fig)

#SET 4
aa<-4
bb<-14
cc<-24
dd<-34
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set4Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 4, 14, 24, & 34", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set4Fig)

#SET 5
aa<-5
bb<-15
cc<-25
dd<-35
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set5Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 5, 15, 25, & 35", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set5Fig)

#SET 6
aa<-6
bb<-16
cc<-26
dd<-36
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set6Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 6, 16, 26, & 36", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set6Fig)

#SET 7
aa<-7
bb<-17
cc<-27
dd<-37
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set7Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 7, 17, 27, & 37", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set7Fig)


#SET 8
aa<-8
bb<-18
cc<-28
dd<-38
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set8Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 8, 18, 28, & 38", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set8Fig)

#SET 9
aa<-9
bb<-19
cc<-29
dd<-39
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set9Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 9, 19, 29, & 39", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set9Fig)

#SET 10
aa<-10
bb<-20
cc<-30
dd<-40
Order<-c(aa,bb,cc,dd)
Gamez<-c(GameProps[aa], GameProps[bb], GameProps[cc], GameProps[dd])
SEz<-c(SE[aa], SE[bb], SE[cc], SE[dd])
df<- data.frame(Order,Gamez, SEz) 
Set10Fig<- ggplot(df, aes(x=Orderz, y=Gamez)) + geom_pointrange(aes(ymin=Gamez-SEz, ymax=Gamez+SEz))+labs(title="Games 10, 20, 30, & 40", x="", y = "Prop. in Action X")+theme_classic()+ylim(.10,.75)
#print(Set10Fig)

grid.arrange(Set1Fig, Set2Fig, Set3Fig, Set4Fig, Set5Fig, Set6Fig, Set7Fig, Set8Fig, Set9Fig, Set10Fig, ncol = 5, nrow = 2)


#Statistical Kruskil Wallace tests for each set.("GameSet" must be changed for each set)
GameSet<-c(Game1, Game11, Game21, Game31)
Type<-c("b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1", "b1",         "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2", "b2",         
        "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3", "b3",         "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4", "b4")
KSdata <- data.frame(GameSet, Type)
kruskal.test(GameSet ~ Type, data = KSdata)


